package mock.servicesdirectory.services.web.action;

import java.util.ArrayList;
import java.util.List;

import mock.servicesdirectory.services.web.model.Premise;


import com.opensymphony.xwork2.ActionSupport;

public class ServiceDetailPremiseAction extends ActionSupport {
	private List<Premise> gridModel;	
	private Integer rows = 0;	
	private Integer page = 0;	
	private String sord;	
	private String sidx;
	private String searchField;
	private String searchString;
	private String searchOper;	
	private Integer total = 0;
	private Integer records = 0;
	
	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	public String getSearchOper() {
		return searchOper;
	}

	public void setSearchOper(String searchOper) {
		this.searchOper = searchOper;
	}

	public String getSearchString() {
		return searchString;
	}

	public void setSearchString(String searchString) {
		this.searchString = searchString;
	}

	public String getSearchField() {
		return searchField;
	}

	public void setSearchField(String searchField) {
		this.searchField = searchField;
	}

	public String getSidx() {
		return sidx;
	}

	public void setSidx(String sidx) {
		this.sidx = sidx;
	}

	public String getSord() {
		return sord;
	}

	public void setSord(String sord) {
		this.sord = sord;
	}

	public List<Premise> getGridModel() {
		return gridModel;
	}

	public void setGridModel(List<Premise> gridModel) {
		this.gridModel = gridModel;
	}

	public String execute() {		
		records = 30;
		rows = 10;
		Premise item;
		List<Premise> service = new ArrayList<Premise>();		
		for (int i = 1; i < 30; i++) {
			item = new Premise();
			item.setName("a");
			item.setAddress("b");
			item.setPhoneNumber("897321498");
			item.setProjectCode("8327489");
			service.add(item);
		}
		
		setGridModel(service);

		setTotal((int) Math.ceil((double) records / (double) rows));

		return SUCCESS;
	}

	public String getJSON() {
		return execute();
	}		
	
	public String associateNewPremise(){
		return SUCCESS;
	}
}
